import {DataTableColumns, NImage, NSpace, NSwitch, NTag} from "naive-ui";
import {useColumns} from "@/views/pages/system/user/useColumns";
import {setting} from "@/config/setting";
import {h} from "vue";
import {eventBus} from "@/config/eventBus";

const {logo} = setting

const {
    useRenderSexById,
    useRenderDeptNameById,
    useRenderRoleNameByIds,
    useRenderPostNameByIds
} = useColumns()

/**
 * 状态的点击事件
 * @param row
 */
const handleSwitchClick = (row: any) => {
    eventBus.emit("handleUserStatusSwitchClick", row)
}

export const columns: DataTableColumns<any> = [
  {
    title: "邮箱号",
    key: "email",
    width: 200
  },
  {
    title: "生效时间",
    key: "expStartTime",
    width: 250
  },
  {
    title: "失效时间",
    key: "expEndTime",
    width: 250
  },
    {
        title: "状态",
        key: "status",
        width: 150,
        render: (row) => (
            h(NSwitch, {
                value: row.status === "0",
                onClick: () => handleSwitchClick(row)
            }, {
                checked: () => "正常",
                unchecked: () => "禁用"
            })
        )
    },
    {
        title: "创建时间",
        key: "createTime",
        width: 200
    },
    {
        title: "更新时间",
        key: "updateTime",
        width: 200
    }
]